#include <stdio.h>
#include <stdlib.h>


/*
 * fflush - flush a stream
 *
 * int fflush(FILE *stream);
 * 
 * the types of buffer :
 * 	line buffer : refresh when "\n", full or force refresh (fflush()). (stdout is line buffer, because it is terminal)
 * 	full buffer : refresh when full or force refresh (fflush()). (as long as it is not a terminal)
 * 	unbuffered : such as stderr, needs to be output immediately
 *
 * we can change the buffer by setvbuf(), setvbuf() function may be used on any open stream to change its buffer. The mode argument must be one of the following three macros:
 * 	_IONBF unbuffered
 *      _IOLBF line buffered
 *      _IOFBF fully buffered
 *
 */

int main()
{
	int i;
	
	// if without "\n", the string below will not print 
	printf("before while()1\n");
	printf("before while()2");
	fflush(stdout);
	printf("before while()3");

	while(1);

	printf("after while()");

	exit(0);
}
